package ckw.database;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

public class VotingCard extends core.modules.database.SuperVotingCard implements
		Serializable {

	private static final long serialVersionUID = -5656093963170980377L;

	private Election election;
	private Set<VotingSubcard> votingSubcards = new HashSet<VotingSubcard>();

	public VotingCard() {
		super();
	}

	public VotingCard(String name, String description) {
		super(name, description);
	}

	public VotingCard(String name, String description, Election election) {
		super(name, description);
		addToElection(election);
	}

	public Election getElection() {
		return election;
	}

	public void setElection(Election election) {
		this.election = election;
	}
	
	public void addToElection(Election election){
		setElection(election);
		election.getVotingCards().add(this);
	}
	
	public void removeFormElection(Election election){
		setElection(null);
		election.getVotingCards().remove(this);
	}

	public Set<VotingSubcard> getVotingSubcards() {
		return votingSubcards;
	}

	public void setVotingSubcards(Set<VotingSubcard> votingSubcards) {
		this.votingSubcards = votingSubcards;
	}

	public void addToVotingSubcard(VotingSubcard votingSubcard) {
		this.getVotingSubcards().add(votingSubcard);
		votingSubcard.setVotingCard(this);
	}

	public void removeFromVotingSubcard(VotingSubcard votingSubcard) {
		this.getVotingSubcards().remove(votingSubcard);
		votingSubcard.setVotingCard(null);
	}
}
